﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;

namespace MvcControl.Extensions
{
    public static class ImageExtendtion
    {
        /// <summary>
        /// Images the specified helper.
        ///  </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="url">The URL.</param>
        /// <param name="altText">The alt text.</param>
        /// <param name="htmlAttributes">The HTML attributes.</param>
        /// <returns></returns>
        public static string Image(this HtmlHelper helper,
                                string url,
                                string altText,
                                object htmlAttributes)
        {
            TagBuilder builder = new TagBuilder("img");
            builder.Attributes.Add("src", url);
            builder.Attributes.Add("alt", altText);
            builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));
            return builder.ToString(TagRenderMode.SelfClosing);
        } 
    }
}
